﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using ProyectoCaminada.usuario;


namespace ProyectoCaminada
{
    public partial class login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
        {
            /*call the login service*/
            LoginService loginService = new LoginService();
            bool validUser = loginService.Login(loginComponent.UserName,
                loginComponent.Password);
            if (validUser)
            {
                CaminanteDAO dao = new CaminanteDAO();;
                Session["user"] =  dao.getCaminanteByUserName(loginComponent.UserName);
                Response.Redirect("home.aspx");
            }
            else
            {
                Response.Redirect("login.aspx");
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Redirect("registro.aspx");
        }
    }
}
